package com.yf.zzmusic.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 接口统一返回封装类
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result {
    private Integer code;
    private String msg;
    private Object data;

    public static Result success(){
        return new Result(Constants.CODE_SUCCESS,"",null);
    }
    public static Result success(Object data){
        return new Result(Constants.CODE_SUCCESS,"",data);
    }
    public static Result success(String msg,Object data){
        return new Result(Constants.CODE_SUCCESS,msg,data);
    }

    public static Result error(String msg){
        return new Result(Constants.CODE_ERROR,msg,null);
    }
    public static Result error(Integer code){
        return new Result(code,"",null);
    }
    public static Result error(){
        return new Result(Constants.CODE_ERROR,"系统错误",null);
    }

    public static Result error(Integer code, String message) {
        return new Result(Constants.CODE_ERROR,message,null);
    }
}
